/// <reference path="../../../../phaser.d.ts" />

import {
  GameScene
} from "./scene/gameScene"
import {
  LoadScene
} from "./scene/loadScene"
import {
  OverScene
} from "./scene/overScene"


var config = {
  type: Phaser.AUTO,
  width: 500,
  heigth: 500,
  backgroundColor: '#abf3ff',
  parent: 'brick',
  physics: {
    default: 'arcade'
  },
  scene: [LoadScene, GameScene, OverScene]
}

export function load() {
  var game = new Phaser.Game(config)
  
  // 屏幕兼容 全屏
  var canvas = document.querySelector('canvas');
  var windowWidth = window.innerWidth;
  var windowHeight = window.innerHeight;
  var windowRatio = windowWidth / windowHeight;
  var gameRatio = game.config.width / game.config.height;
  if (windowRatio < gameRatio) {
    canvas.style.width = windowWidth + 'px';
    canvas.style.height = (windowWidth / gameRatio) + 'px';
  } else {
    canvas.style.width = (windowHeight * gameRatio) + 'px';
    canvas.style.height = windowHeight + 'px';
  }
}
